package test.study.db.sql.calcite;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.calcite.config.Lex;
import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.parser.SqlParser;
import org.junit.Test;

@Slf4j
public class Demo {

    @SneakyThrows
    @Test
    public void test() {

        String sql = "select * from user_base";

        SqlParser.Config mysqlConfig = SqlParser.config().withLex(Lex.MYSQL);
        SqlParser parser = SqlParser.create(sql, mysqlConfig);
        SqlSelect sqlNode = (SqlSelect)parser.parseQuery(sql);
        log.info("{}", sqlNode.getFrom());
      }
}
